<?php
  require_once('fpdf/fpdf.php');
  require_once('includes/constants.php');  
  require_once('includes/database.php');
  require_once('DeliveryNotePDF.php');
  extract($_REQUEST);
  session_start();

	$selectedTasks = $_SESSION[TASKS];
  $pdf = new DeliveryNotePDF();
  $pdf->AliasNbPages();
  $pdf->SetMargins(10, 20, 10);

	
   	$pdf->AddPage("L");
  	$pdf->SetFillColor(231, 231, 255);
  	$pdf->Ln(20);
  	$pdf->SetFont('Arial', 'B', 14);
  	$pdf->Cell(30, 8, "TASK LIST", 0, 1);
	$pdf->Cell(0 , 1 , "" , 0 , 1 ,"C" , "1");
	$pdf->SetFont('Arial', 'B', 8);
	$theTime = strftime("%Y-%m-%d %H:%M:%S", strtotime("now"));
	$pdf->Ln(10);
	$pdf->Write(10, $theTime);
	$pdf->Ln();	

  	$pdf->Cell(30, 6, "Order ID",1,0,"C",1 );
  	$pdf->Cell(20, 6, "Order Due",1,0,"C",1);
  	$pdf->Cell(15, 6, "Item ID",1,0,"C",1);
  	$pdf->Cell(20, 6, "Item Due", 1,0,"C",1);
  	$pdf->Cell(15, 6, "Emp.ID",1,0,"C",1);
  	$pdf->Cell(40, 6, "Employee",1,0,"C",1);
  	$pdf->Cell(10, 6, "Hours",1,0,"C",1);
  	$pdf->Cell(20, 6, "Garment ID", 1,0,"C",1);
  	$pdf->Cell(20, 6, "Fabric ID",1,0,"C",1);
  	$pdf->Cell(75, 6, "Size Info",1,0,"C",1);
	$pdf->Ln();
	
  foreach ($selectedTasks as $taskData) {
	  	$pdf->Cell(30, 6, $taskData['o_order_id'],1,0,"C"  );
	  	$pdf->Cell(20, 6, $taskData['o_due_date'],1,0,"C" );
	  	$pdf->Cell(15, 6, $taskData['oi_item_id'],1,0,"C" );
	  	$pdf->Cell(20, 6, $taskData['t_date_assigned'], 1,0,"C" );
	  	$pdf->Cell(15, 6, $taskData['t_employee_id'],1,0,"C" );
	  	$pdf->Cell(40, 6, $taskData['e_firstname'] . " " .  $taskData['e_surname'],1,0,"C" );
	  	$pdf->Cell(10, 6, $taskData['t_hours_of_work'],1,0,"C" );
	  	$pdf->Cell(20, 6, $taskData['oi_garment_id'], 1,0,"C" );
	  	$pdf->Cell(20, 6, $taskData['oi_fabric_id'],1,0,"C" );
	  	$pdf->Cell(75, 6, getSizeInfo($taskData),1,0,"C" );
		$pdf->Ln();  

  }
	

$pdf->Output("taskList.pdf", "D");
?>